home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.postrm < prev    next >
Encoding:
Text File  |  2009-05-14  |  5.0 KB  |  188 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # After the package was removed:
  5. #    <postrm> remove
  6. #
  7. # After the package was purged:
  8. #    <postrm> purge
  9. #
  10. # After the package was upgraded:
  11. #    <old-postrm> upgrade <new-version>
  12. # if that fails:
  13. #    <new-postrm> failed-upgrade <old-version>
  14. #
  15. #
  16. # After all of the packages files have been replaced:
  17. #    <postrm> disappear <overwriting-package> <version>
  18. #
  19. #
  20. # If preinst fails during install:
  21. #    <new-postrm> abort-install
  22. #
  23. # If preinst fails during upgrade of removed package:
  24. #    <new-postrm> abort-install <old-version>
  25. #
  26. # If preinst fails during upgrade:
  27. #    <new-postrm> abort-upgrade <old-version>
  28.  
  29.  
  30. # Undo removal of a no-longer used conffile
  31. undo_rm_conffile()
  32. {
  33.     CONFFILE="$1"
  34.  
  35.     if [ ! -e "$CONFFILE" ]; then
  36.     if [ -e "$CONFFILE".dpkg-bak ]; then
  37.         echo "Restoring modified conffile $CONFFILE"
  38.         mv -f "$CONFFILE".dpkg-bak "$CONFFILE"
  39.     elif [ -e "$CONFFILE".dpkg-obsolete ]; then
  40.         mv -f "$CONFFILE".dpkg-obsolete "$CONFFILE"
  41.     fi
  42.     fi
  43. }
  44.  
  45. # Finish removal of a no-longer used conffile
  46. finish_rm_conffile()
  47. {
  48.     CONFFILE="$1"
  49.  
  50.     if [ -e "$CONFFILE".dpkg-bak ]; then
  51.     rm -f "$CONFFILE".dpkg-bak
  52.     fi
  53. }
  54.  
  55. # Undo move of a conffile
  56. undo_mv_conffile()
  57. {
  58.     CONFFILE="$1"
  59.  
  60.     if [ ! -e "$CONFFILE" ]; then
  61.     if [ -e "$CONFFILE".dpkg-bak ]; then
  62.         mv -f "$CONFFILE".dpkg-bak "$CONFFILE"
  63.     elif [ -e "$CONFFILE".dpkg-moving ]; then
  64.         mv -f "$CONFFILE".dpkg-moving "$CONFFILE"
  65.     fi
  66.     fi
  67. }
  68.  
  69. # Finish move of a conffile
  70. finish_mv_conffile()
  71. {
  72.     CONFFILE="$1"
  73.  
  74.     if [ -e "$CONFFILE".dpkg-bak ]; then
  75.     rm -f "$CONFFILE".dpkg-bak
  76.     fi
  77. }
  78.  
  79.  
  80. # Enable udevadm again
  81. enable_udevadm()
  82. {
  83.     rm -f /sbin/udevadm
  84.     dpkg-divert --local --rename --divert /sbin/udevadm.upgrade \
  85.             --remove /sbin/udevadm
  86. }
  87.  
  88.  
  89. # Undo remove of Ubuntu rules in favour of upstream ones
  90. undo_rm_ubuntu_rules()
  91. {
  92.     undo_rm_conffile /etc/udev/rules.d/05-options.rules
  93.     undo_rm_conffile /etc/udev/rules.d/05-udev-early.rules
  94.     undo_rm_conffile /etc/udev/rules.d/20-names.rules
  95.     undo_rm_conffile /etc/udev/rules.d/30-cdrom_id.rules
  96.     undo_rm_conffile /etc/udev/rules.d/40-basic-permissions.rules
  97.     undo_rm_conffile /etc/udev/rules.d/40-permissions.rules
  98.     undo_rm_conffile /etc/udev/rules.d/60-persistent-input.rules
  99.     undo_rm_conffile /etc/udev/rules.d/60-persistent-storage-tape.rules
  100.     undo_rm_conffile /etc/udev/rules.d/60-persistent-storage.rules
  101.     undo_rm_conffile /etc/udev/rules.d/60-symlinks.rules
  102.     undo_rm_conffile /etc/udev/rules.d/61-persistent-storage-edd.rules
  103.     undo_rm_conffile /etc/udev/rules.d/65-id-type.rules
  104.     undo_rm_conffile /etc/udev/rules.d/66-persistent-storage-edd.rules
  105.     undo_rm_conffile /etc/udev/rules.d/75-cd-aliases-generator.rules
  106.     undo_rm_conffile /etc/udev/rules.d/75-persistent-net-generator.rules
  107.     undo_rm_conffile /etc/udev/rules.d/80-programs.rules
  108.     undo_rm_conffile /etc/udev/rules.d/90-modprobe.rules
  109.     undo_rm_conffile /etc/udev/rules.d/95-udev-late.rules
  110. }
  111.  
  112. # Finish remove of Ubuntu rules in favour of upstream ones
  113. finish_rm_ubuntu_rules()
  114. {
  115.     finish_rm_conffile /etc/udev/rules.d/05-options.rules
  116.     finish_rm_conffile /etc/udev/rules.d/05-udev-early.rules
  117.     finish_rm_conffile /etc/udev/rules.d/20-names.rules
  118.     finish_rm_conffile /etc/udev/rules.d/30-cdrom_id.rules
  119.     finish_rm_conffile /etc/udev/rules.d/40-basic-permissions.rules
  120.     finish_rm_conffile /etc/udev/rules.d/40-permissions.rules
  121.     finish_rm_conffile /etc/udev/rules.d/60-persistent-input.rules
  122.     finish_rm_conffile /etc/udev/rules.d/60-persistent-storage-tape.rules
  123.     finish_rm_conffile /etc/udev/rules.d/60-persistent-storage.rules
  124.     finish_rm_conffile /etc/udev/rules.d/60-symlinks.rules
  125.     finish_rm_conffile /etc/udev/rules.d/61-persistent-storage-edd.rules
  126.     finish_rm_conffile /etc/udev/rules.d/65-id-type.rules
  127.     finish_rm_conffile /etc/udev/rules.d/66-persistent-storage-edd.rules
  128.     finish_rm_conffile /etc/udev/rules.d/75-cd-aliases-generator.rules
  129.     finish_rm_conffile /etc/udev/rules.d/75-persistent-net-generator.rules
  130.     finish_rm_conffile /etc/udev/rules.d/80-programs.rules
  131.     finish_rm_conffile /etc/udev/rules.d/90-modprobe.rules
  132.     finish_rm_conffile /etc/udev/rules.d/95-udev-late.rules
  133. }
  134.  
  135.  
  136. # Remove configuration and log files
  137. purge_files()
  138. {
  139.     if [ -f /etc/iftab ]; then
  140.     rm -f /etc/iftab || true
  141.     fi
  142.  
  143.     if [ -f /var/log/udev ]; then
  144.     rm -f /var/log/udev || true
  145.     fi
  146. }
  147.  
  148.  
  149. case "$1" in
  150.     remove)
  151.     ;;
  152.  
  153.     purge)
  154.         finish_rm_ubuntu_rules
  155.     purge_files
  156.     ;;
  157.  
  158.     upgrade|failed-upgrade|disappear)
  159.     ;;
  160.  
  161.     abort-install|abort-upgrade)
  162.     # Abort upgrade from intrepid
  163.     if dpkg --compare-versions "$2" lt "136-4"; then
  164.         undo_rm_ubuntu_rules
  165.     fi
  166.  
  167.     enable_udevadm
  168.     ;;
  169.  
  170.     *)
  171.     echo "$0 called with unknown argument \`$1'" 1>&2
  172.     exit 1
  173.     ;;
  174. esac
  175.  
  176. # Automatically added by dh_installinit
  177. if [ "$1" = "purge" ] ; then
  178.     update-rc.d udev-finish remove >/dev/null || exit $?
  179. fi
  180. # End automatically added section
  181. # Automatically added by dh_installinit
  182. if [ "$1" = "purge" ] ; then
  183.     update-rc.d udev remove >/dev/null || exit $?
  184. fi
  185. # End automatically added section
  186.  
  187. exit 0
  188.